package br.edu.sistemaacademico.dao;



import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import br.edu.sistemaacademico.helper.Conexao;

public abstract class DaoGenerico implements IDao{

	
	public Statement getStatement() throws SQLException{
		return Conexao.getConexao().createStatement();
	}
	
	public PreparedStatement getStatement(String str) throws SQLException{
		return Conexao.getConexao().prepareStatement(str);
	}
	
	public ResultSet executeQuery(String query) throws SQLException{
		PreparedStatement ps = getStatement(query);
		return ps.executeQuery();
	}
	
	public int executeCommand(String query) throws SQLException{
		PreparedStatement ps = getStatement(query);
		int result = ps.executeUpdate();
		ps.close();
		return result;
	}
}
